﻿@using Coralcode.Adapter.StatVisit.Entity.Domains
@using Coralcode.Utils.Basic
@using CoralNode.MvcClient.Helper
@{
    ViewBag.Title = "访客分析-忠诚度";
    ViewBag.PageModule = "visitor";
    ViewBag.CurrentPageUrl = "/m/statistic/visitorloyalty?orderfield=" + ViewBag.orderfield + "&orderDirection=" + ViewBag.orderDirection + "&";
    var order = ViewBag.orderDirection == "up" ? "class=order_up" : "class=order_down";
}
@Html.IncludePage("CoralAdmin/statistic", "_Left")
<!--content-->
<div id="pbody">
    <div class="extra">
        @Html.IncludePage("CoralAdmin/statistic", "DateSelection")
        <div class="main-box mt_2 mb_2">
            <div class="tab-visit clearfix">
                <a href="/m/statistic/visitor?dateStart=@ViewBag.DateStart&dateEnd=@ViewBag.DateEnd&dateselect=@ViewBag.dateselecte">地区分布</a>
                <a href="/m/statistic/visitorisp?dateStart=@ViewBag.DateStart&dateEnd=@ViewBag.DateEnd&dateselect=@ViewBag.dateselecte">网络运营商</a>
                <a href="/m/statistic/visitordevice?dateStart=@ViewBag.DateStart&dateEnd=@ViewBag.DateEnd&dateselect=@ViewBag.dateselecte">终端详情</a>
                <a href="/m/statistic/visitorisnew?dateStart=@ViewBag.DateStart&dateEnd=@ViewBag.DateEnd&dateselect=@ViewBag.dateselecte">新老访客</a>
                <a class="current" href="/m/statistic/visitorloyalty?dateStart=@ViewBag.DateStart&dateEnd=@ViewBag.DateEnd&dateselect=@ViewBag.dateselecte">忠诚度</a>
                <a href="/m/statistic/visitoractiveness?dateStart=@ViewBag.DateStart&dateEnd=@ViewBag.DateEnd&dateselect=@ViewBag.dateselecte">活跃度</a>
            </div>
            <div class="clearfix">
                <div class="table_visit">
                    <table width="100%" style="margin-top:2px;">
                        <thead>
                            <tr class="t_bg headRow">
                                <td width="10"></td>
                                <td>日访问频度</td>
                                <td></td>
                                <td align="right">独立访客（UV）|</td>
                                <td><div class="l"><a @if (ViewBag.orderField == "uv") {@String.Format(order)}else{@String.Format("class=order_none")} orderField="uv"><i></i>占比</a></div></td>
                                <td align="right">浏览次数（PV）|</td>
                                <td><div class="l"><a @if (ViewBag.orderField == "pvpercent") {@String.Format(order)}else{@String.Format("class=order_none")} orderField="pvpercent"><i></i>占比</a></div></td>
                            </tr>
                        </thead>
                        <tbody>
                            @for (int i = 0; i < ViewBag.SummaryReports.Count; i++) {
                                StatReportDomain report = ViewBag.SummaryReports[i];
                                <tr @if (i == ViewBag.SummaryReports.Count - 1) {@String.Format("class=last")}>
                                    <td></td>
                                    <td>@report.StatName</td>
                                    <td align="center"><a class="ml_1-5" href="#"><i class="ico ico_visit_time"></i></a></td>
                                    <td align="right">@report.UniqueVisitor</td>
                                    <td><div class="visit_bar"><span style="width:@MathUtil.RoundPercent(report.UniqueVisitorPercent)%"></span><div>@MathUtil.RoundPercent(report.UniqueVisitorPercent)%</div></div></td>
                                    <td align="right">@report.PageView</td>
                                    <td><div class="visit_bar"><span style="width:@MathUtil.RoundPercent(report.PageViewPercent)%"></span><div>@MathUtil.RoundPercent(report.PageViewPercent)%</div></div></td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>
            </div> 
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $(".headRow a").css("cursor", "pointer").click(function () {
            var orderField = $(this).attr("orderField");
            var orderDirection = ($(this).hasClass("order_none") || $(this).hasClass("order_up"))?"down":"up";
            window.location = "/m/statistic/visitorloyalty?dateStart=@ViewBag.DateStart&dateEnd=@ViewBag.DateEnd&dateselect=@ViewBag.dateselecte&orderfield=" + orderField + "&orderDirection=" + orderDirection;
        });
    });
</script>